<template>
	<view class="route-item flex--col" @click="handleClick" aria-label="点击展开所有正在请求的路线">
		<view class="route-item-info flex--col">
			<text class="text--main-dark"> {{ route.name }} </text>
			<text class="text--secondary-dark"> {{ `${route.distance}KM ${route.time}h` }}</text>
		</view>
		<view class="route-item-spots" v-if="showDetail" >
			<view class="spots-order flex--row">
				<view v-for="(route,index) in route.routeAttractionsList" class="flex--row spots-order-item">
					<view class="order-number text--secondary-dark" :class="{'active':index === spotIndex}" @click.stop="spotIndex = index">{{index + 1}}</view>
					<image aria-label="箭头" src="@/static/arrow.svg" class="icon--small"></image>
				</view>
			</view>
			<view class="spots-detail flex--row">
				<view class="detail--side flex--row">
					<view class="detail-image icon--large">
						<image :aria-label="route.routeAttractionsList[spotIndex].attractionsName+'照片'"  :src="route.routeAttractionsList[spotIndex].img" mode="center"></image>
					</view>
					<view class="detail-desc flex--col">
						<text class="text--secondary-dark">{{ route.routeAttractionsList[spotIndex].attractionsName }}</text>
						<text class="text--thirdary-dark">{{ route.routeAttractionsList[spotIndex].description }}</text>
					</view>
				</view>
				<view class="detail--side">
					<image :aria-label="'第'+(spotIndex+1)+'站'"  :src="`../../static/numbers/${spotIndex+1}.svg`" class="icon"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>	
	export default{
		data(){
			return {
				spotIndex:0
			}
		},
		methods:{
			handleClick(){
				
				this.$emit('clickroute',this.route.travelId)
			}
		},
		emits:['clickroute'],
		props:['route','showDetail'],
		
		mounted(){
			
		}
	}
</script>

<style lang="scss" scoped>
	.text--main-dark{
		font-size: 24px;
		font-weight: 700;
		color:#333;
	}
	
	.text--secondary-dark{
		font-size: 16px;
		font-weight: 600;
		color:#333;
	}
	
	.text--thirdary-dark{
		font-size: 14px;
		font-weight: 400;
		color:#333;
	}
	
	.order-number{
		text-align: center;
		width:18px;
		height:18px;
		padding:4px;
		border-radius: 50%;
		border:1px solid #333;
		
		
		&.active{
			background-color: #333;
			color:#fff;
		}
	}
	
	.route-item{
		@include border-four-roundings;
		padding:20px 10px;
		background-color: #fff;
		box-sizing: border-box;
		width:600rpx;
		gap:24px;
	}
	
	.route-item-info{
	   justify-content: center;
	   align-items: center;
	   gap:12px;
	}
	
	.route-item-spots{
		.spots-order{
			gap:4px;
			justify-content: center;
			align-items: center;
			
			margin-bottom: 8px;
			
			&-item{
				align-items: center;
				gap:2px;
			}
			
			&-item:last-child image{
				align-items: center;
				gap:2px;
				display: none;
			}
			
			
		}

		.spots-detail{
			justify-content: space-around;
			align-items: center;
		}
		
		.detail--side{
			gap:4px;
		}
		
		.detail-image{
			@include border-four-roundings;
			overflow: hidden;
			padding:2px;
			
			image{
				width:100%;
				height:100%;
				border-radius: 10px;
			}
		}
		
		.detail-desc{
			padding:6px 0px;
			justify-content: space-between;
		}
		
	
	}
	
	
</style>